package com.engineering.elink.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.engineering.elink.dao.UserMapper;
import com.engineering.elink.service.AuthService;
import com.engineering.elink.service.TokenAuthenticationService;

@Service
public class AuthServiceImpl implements AuthService{

	@Autowired
	private TokenAuthenticationService tokenAuthenticationService;
	@Autowired
	private UserMapper userMapper;
	
	@Override
	public String checkAuthToken(String seed, String authToken) {
		return tokenAuthenticationService.getAuthTokenInfo(seed, authToken);
	}

	@Override
	public Map<String,Object> getUserInfo(String userId) {
		// TODO Auto-generated method stub
		return userMapper.selectByUserId(userId);
	}

	@Override
	public Map<String, Object> checkAuth(String seed, String authToken,
			String path) {
		// TODO Auto-generated method stub
		String userId = tokenAuthenticationService.getAuthTokenInfo(seed, authToken);
		if (userId != null) {
			 return userMapper.selectByUserId(userId);
		}
		return null;
	}

}
